﻿@using VocaDb.Model.Domain.Security
@using VocaDb.Web.Helpers
@inherits VocaDb.Web.Code.VocaDbPage

<div data-bind="with: selectedTopic()">
	
	<div data-bind="visible: !isBeingEdited()">
		
		<div class="well well-transparent">
			<h3 data-bind="text: contract().name"></h3>

			<div data-bind="with: contract">
				@CommentHelpers.CommentKnockout("content", true, "$parents[1].deleteTopic", "$parent.beginEditTopic")
			</div>

		</div>	

	</div>
	
	<form data-bind="visible: isBeingEdited, submit: saveEditedTopic" class="well well-transparent">
		<div data-bind="with: editModel">
			@{ Html.RenderPartial("Partials/_EditTopic"); }
		</div>
		<button type="submit" class="btn btn-primary">@ViewRes.SharedStrings.Save</button>
		<button data-bind="click: cancelEdit" class="btn">@ViewRes.SharedStrings.Cancel</button>
	</form>
	
	<div data-bind="with: comments, visible: !contract().locked">
		@CommentHelpers.EditableComments(UserContext.HasPermission(PermissionToken.CreateComments), commentBoxEnd: true)
	</div>
	<div class="alert" data-bind="visible: contract().locked">
		Comments have been disabled for this topic.
	</div>

</div>
